using System.Collections.Generic;
using System.Text;

namespace OracleInternal.SqlAndPlsqlParser.LocalParsing.Ansi
{
	internal class OracleLpJoinedTable : OracleLpStatementDataContainer
	{
		protected OracleLpTableReferenceAnsi m_vTableReference;

		protected OracleLpBaseAnsiJoinClause m_vJoinClause;

		protected List<OracleLpColumnDescriptor> m_vColumnDescriptors;

		internal override OracleLpStatementElementType ElementType => OracleLpStatementElementType.JoinedTable;

		public OracleLpTableReferenceAnsi TableReference
		{
			get
			{
				return m_vTableReference;
			}
			set
			{
				m_vTableReference = value;
				if (m_vTableReference != null)
				{
					m_vTableReference.Parent = this;
				}
			}
		}

		public OracleLpBaseAnsiJoinClause JoinClause
		{
			get
			{
				return m_vJoinClause;
			}
			set
			{
				m_vJoinClause = value;
				if (m_vJoinClause != null)
				{
					m_vJoinClause.Parent = this;
				}
			}
		}

		public override List<OracleLpColumnDescriptor> ColumnDescriptors
		{
			get
			{
				if (m_vColumnDescriptors == null)
				{
					Resolve();
				}
				return m_vColumnDescriptors;
			}
		}

		public OracleLpJoinedTable(OracleLpStatementElement se)
			: base(se)
		{
		}

		public override void Resolve()
		{
			m_vColumnDescriptors = new List<OracleLpColumnDescriptor>();
			m_vColumnDescriptors.AddRange(m_vTableReference.ColumnDescriptors);
			m_vColumnDescriptors.AddRange(m_vJoinClause.ColumnDescriptors);
		}

		public override void RetrieveNamedObjectReferences(OracleLpStatement statement)
		{
			m_vTableReference.RetrieveNamedObjectReferences(statement);
			m_vJoinClause.RetrieveNamedObjectReferences(statement);
		}

		internal override void ToString(StringBuilder sb)
		{
			string depthIndent = base.DepthIndent;
			sb.Append(depthIndent);
		}
	}
}
